﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using Model.Query_Model;
using Interfaces.Information_Interfaces;
using Interfaces.Update_Interfaces;
using Presenters.Update_Presenters;
using Views.Status_Views;

namespace Views.Update_Views
{
    public partial class ValuationUpdateView : Form, IValuationUpdateView
    {
        ValuationUpdatePresenter presenter = null;

        public ValuationUpdateView()
        {
            InitializeComponent();
            presenter = new ValuationUpdatePresenter(this);
        }

        protected override void OnLoad(EventArgs e)
        {
            presenter.SendDataToView();
            base.OnLoad(e);
        }

        CurrencyOutput IValuationUpdateView.currency
        {
            get
            {
                return (CurrencyOutput)newCurrency.SelectedItem;
            }
            set
            {
                newCurrency.SelectedItem = value as CurrencyOutput;
            }
        }

        bool IValuationUpdateView.isDedicated
        {
            get
            {
                return isDedicated.Checked;
            }
            set
            {
                isDedicated.Checked = value;
            }
        }

        string IValuationUpdateView.linkToGoogle
        {
            get
            {
                return newLink.Text;
            }
            set
            {
                newLink.Text = value as string;
            }
        }

        double IValuationUpdateView.value
        {
            get
            {
                return Convert.ToDouble(newValue.Text);
            }
            set
            {
                newValue.Text = value.ToString();
            }
        }

        T Interfaces.Inherited_Interfaces.IView.ReturnView<T>()
        {
            return (T)((object)this);
        }

        void Interfaces.Inherited_Interfaces.IError.ShowError()
        {
            presenter.ShowError(new ErrorView());
        }

        void Interfaces.Inherited_Interfaces.ISuccess.ShowSuccess()
        {
            presenter.ShowSuccess(new SuccessView());
        }

        void Interfaces.General_Interfaces.IParamable.SetParams(params object[] param)
        {
            presenter.road = (RoadOutput)param.Where(x => x.GetType() == typeof(RoadOutput)).Take(1).FirstOrDefault();
        }


        IList<CurrencyOutput> IValuationUpdateView.currencyList
        {
            get
            {
                return (List<CurrencyOutput>)newCurrency.DataSource;
            }
            set
            {
                newCurrency.DataSource = value as List<CurrencyOutput>;
            }
        }
    }
}
